<template>
    <div class="tabcontroller">
        <div class="tab-item" v-for="(item,index) in titles" :key="index" :class="{action:currentIndex==index}" @click="itemClick(index)">
            <span>{{item}}</span>
            </div>
    </div>
</template>
<script>
export default {
    name:'TabController',
    props:{
        titles:{
            type:Array,
            default(){
                return []
            }
        }
    },
    data(){
        return{
            currentIndex:0,
        }
    },
    methods:{
        itemClick(index){
            this.currentIndex=index;
            this.$emit('tabClick',index);
        }
    }
}
</script>
<style scoped>
.tabcontroller{
    display: flex;
    text-align: center;
    height: 40px;
    line-height: 40px;
    font-size: 17px;
}
.tab-item{
    flex: 1;
}
.action{
    color: var(--color-height-text);
}
.action span{
    border-bottom: 1px solid var(--color-height-text);
    padding: 5px;
}
</style>
